﻿public class PlayerStats {
	// === Public =====================================================================================================
	public float Speed { get; private set; }
	public int Score { get; private set; }
	public int Life { get; private set; }

	public static PlayerStats GetInstance {
		get { return _instance ?? (_instance = new PlayerStats()); }
	}

	// === Speed ===
	public void SetSpeed(int value) {
		_startSpeed = Speed = value;
	}

	public void IncreaseSpeed(float value) {
		Speed += value;
	}

	public void ReduceSpeed(float value) {
		Speed -= value;
		if (Speed < _startSpeed) {
			Speed = _startSpeed;
		}
	}

	public void ResetSpeed() {
		Speed = _startSpeed;
	}
	
	// === Score ===
	public void IncreaseScore(int value) {
		Score += value;
	}

	public void ResetScore() {
		Score = 0;
	}

	// === Life ===
	public void ReduceLife(int value = 1) {
		Life -= value;
	}

	public void ResetLife() {
		Life = 3;
	}

	// ===
	public void ResetStats() {
		ResetSpeed();
		ResetScore();
		ResetLife();
	}

	// === Private ====================================================================================================
	private static PlayerStats _instance;
	private float _startSpeed;

	private PlayerStats() {
		_startSpeed = Speed = Constants.MIN_SPEED;
		Score = 0;
		Life = 3;
	}
}